import { createApp } from 'vue'
import { createPinia } from 'pinia'
import { createPersistedState } from "pinia-plugin-persistedstate";
import { getStorage, setStorage, removeStorageSync } from "@tarojs/taro";
import './app.scss'

const App = createApp({
  onShow(options) {
  },
  // 入口组件不需要实现 render 方法，即使实现了也会被 taro 所覆盖
})
const pinia = createPinia();
// 改写storage，使用taro提供的api
const storage = {
  getItem: (key: string) => getStorage({key: key,success: function (res) {
    res.data
  }}),
  setItem: (key: string, value: any) => setStorage({key: key,data: value}),
  removeItem: (key: string) => removeStorageSync(key)
}
pinia.use(createPersistedState({
  auto: true,
  storage: storage
}));

App.use(pinia)

export default App
